<?php

/**
 * @author Laurent SITTLER <lolo.sittler@gmail.com>
 * @author Alexandre GOMEZ <gomez.alexandre02@gmail.com>
 * @version 0.1
 */

/**
 * Database Class
 */
class Database extends PDO {

    /**
     * Contructor
     * Connexion à la base de données Oracle ou MySQL (Interface)
     */
    function __construct() {
        try {
            if (strtoupper($GLOBALS['conf']['interface']['database']['type']) == strtoupper('oracle'))
                parent::__construct('oci:dbname=' . $GLOBALS['conf']['interface']['database']['host'] . ':' . $GLOBALS['conf']['interface']['database']['port'] . '/' . $GLOBALS['conf']['interface']['database']['dbname'] . '', $GLOBALS['conf']['interface']['database']['user'], $GLOBALS['conf']['interface']['database']['password']);
            else if (strtoupper($GLOBALS['conf']['interface']['database']['type']) == strtoupper('mysql'))
                parent::__construct('mysql:host=' . $GLOBALS['conf']['interface']['database']['host'] . ';port=' . $GLOBALS['conf']['interface']['database']['port'] . ';dbname=' . $GLOBALS['conf']['interface']['database']['dbname'] . '', $GLOBALS['conf']['interface']['database']['user'], $GLOBALS['conf']['interface']['database']['password']);
        } catch (PDOException $e) {
            Session::Set(Constants::$SESSION_error, $e->getMessage());
        }
    }

}